import { createRouter, createWebHistory } from "vue-router";
import noFind from "@/components/404.vue";

import pages from "./pages";

const routes = [
  {
    path: "/",
    name: "Home",
    redirect: "/Index",
    component: () => import("@/views/Home.vue"),
  },
  {
    path: "/",
    name: "Home",
    redirect: "/Index",

    component: () => import("@/views/Home.vue"),
    children: [
      // 空页面刷新
      {
        path: "/Kong/:path(.*)",
        name: "Kong",
        component: () => import("@/views/Kong.vue"),
      },

      //子路由
      {
        path: "Index",
        name: "Index",
        meta: {
          title: "首页",
        },
        component: () => import("@/views/Index/Index.vue"),
      },
      // 个人信息
      {
        path: "/User",
        name: "User",
        component: () => import("@/views/Index/User.vue"),
        meta: {
          title: "个人信息",
        },
      },

      // 修改密码
      {
        path: "/Code",
        name: "Code",
        component: () => import("@/views/Index/Code.vue"),
        meta: {
          title: "修改密码",
        },
      },
      // 商品添加
      {
        path: "//bcommodity/ListMulti/listAdd",
        name: "listAdd",
        component: () => import("@/views/bcommodity/ListMulti/listAdd"),
        meta: {
          title: "商品添加",
          keepAlive: true,
        },
      },
      // 商品修改
      {
        path: "//bcommodity/ListMulti/listEdite",
        name: "listEdite",
        component: () => import("@/views/bcommodity/ListMulti/listEdite"),
        meta: {
          title: "商品修改",
          keepAlive: true,
        },
      },
      // 测试信息
      {
        path: "/demo",
        name: "demo",
        component: () => import("@/views/demo.vue"),
        meta: {
          title: "测试",
        },
      },
      ...pages,
    ],
  },

  {
    path: "/Login",
    name: "Login",
    component: () => import("@/views/Login.vue"),
  },

  {
    //404配置设置最底部
    // path: '/:pathMatch(.*)',
    // path: "/:catchAll(.*)",
    path: "/:path(.*)+",
    component: () => import("@/components/404.vue"),
  },
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

export default router;
